private ["_object","_array","_i","_smallest","_nearest"];

_object = _this select 0;
_array = _this select 1;
_i = 0;

_smallest = _object distance  (_array select _i);
_nearest = _array select _i;
while {_i<count _array} do
	{
	if ((_object distance  (_array select _i)) < _smallest) then
		{
		_nearest = (_array select _i);
		_smallest = (_object distance  (_array select _i));
		};
	_i = _i + 1;
	};

_nearest